package com.msh.starter.pinying.config;

import com.msh.frame.client.interfaces.IClassLoadLog;
import com.msh.starter.pinying.instance.DefaultIPinying;
import com.msh.starter.pinying.interfaces.IPinyingIdx;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class PinyingAutoConfiguration implements IClassLoadLog {

  @Bean
  @ConditionalOnProperty(name = "msh.starter.pin-ying.enable", havingValue = "true", matchIfMissing = true)
  public IPinyingIdx pinyingIdx(){
    return new DefaultIPinying();
  }

  @Override
  public String logInfo() {
    StringBuilder sb = new StringBuilder().append("----执行类 ")
        .append(PinyingAutoConfiguration.class)
        .append("\r\n")
        .append("--------加载类 ")
        .append(DefaultIPinying.class)
        .append("(IPinyingIdx)\r\n");
    return sb.toString();
  }
}
